//
//  VIPViewController.m
//  copyrightTrading
//
//  Created by 郭子一 on 2020/10/5.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "VIPViewController.h"
#import "JXCategoryTitleView.h"
#import "VIPVideoViewController.h"
#import "VIPVoiceViewController.h"
#import "VIPPictureViewController.h"
@interface VIPViewController ()
@property (nonatomic, strong) JXCategoryTitleView *myCategoryView;
@end

@implementation VIPViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self requestData];
    
    
}

- (void)requestData
{
//    [NSThread sleepForTimeInterval:2];
    if (self.titles == nil) {
        self.titles = @[@"视频下载", @"音频下载", @"图片下载"];
    }
    
    self.myCategoryView.titles = self.titles;
    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    lineView.indicatorWidth = 60;
    lineView.indicatorHeight = 4;
    self.myCategoryView.indicators = @[lineView];
    
    self.myCategoryView.titleFont = JSS_MEDIUM_FONT_4;
}

- (void)setupUI
{
    UIView *headerView = [UIView new];
    headerView.backgroundColor = RGB_VALUE(0xDC0000);
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.offset(0);
        make.height.mas_equalTo(Height_NavBar);
    }];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = @"VIP下载专区";
    titleLabel.font = JSS_MEDIUM_FONT(17);
    titleLabel.textColor = RGB_VALUE(0xFFFFFF);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [headerView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-9);
        make.centerX.offset(0);
        make.width.mas_equalTo(135);
        make.height.mas_equalTo(24);
    }];
}

- (void)observeNetWork {
    WeakSelf(self);
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        if (status == AFNetworkReachabilityStatusNotReachable || status == AFNetworkReachabilityStatusUnknown) {
            //无网络链接
            NSLog(@"==无网络链接");
        } else {
            //网络链接成功
            
            NSLog(@"==网络链接成功");
        }
    }];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    self.categoryView.frame = CGRectMake(0, Height_NavBar, self.view.bounds.size.width, [self preferredCategoryViewHeight]);
    self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight] + Height_NavBar, self.view.bounds.size.width, self.view.bounds.size.height);
}

- (JXCategoryTitleView *)myCategoryView {
    return (JXCategoryTitleView *)self.categoryView;
}

- (JXCategoryBaseView *)preferredCategoryView {
    return [[JXCategoryTitleView alloc] init];
}

#pragma mark - JXCategoryListContainerViewDelegate
//根据下标index返回对应遵从`JXCategoryListContentViewDelegate`协议的列表实例
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    if (index == 0) {
        VIPVideoViewController *vc = [[VIPVideoViewController alloc] init];
        return vc;
    } else if (index == 1) {
        VIPVoiceViewController *vc = [[VIPVoiceViewController alloc] init];
        return vc;
    } else {
        VIPPictureViewController *vc = [[VIPPictureViewController alloc] init];
        return vc;
    }
    
}
@end
